<template>
  <span style="display:flex">
    <img src="../assets/images/cart.png" alt=""> &nbsp;
<router-link to="/cart" style="font-size:25px;line-height:60px;text-decoration:none;color:#719CC6;font-weight:bold;font-family:cursive">
     购物车({{count || 0}})
</router-link>
  </span>
</template>

<script>
import {mapState} from "vuex"
export default {
   data(){
    return {
      count:0,
    }
  },
   created(){
      if (this.user != null) {
        this.axios.post('/api/carts/getCount',{uid:this.user.uid}).then(res=>{
          this.count=res.data.data;
        }).catch(err=>{
          alert(err.message);
        })
      }
  },
computed:{
  ...mapState('user',['user']),
}
}
</script>

<style>
/* span{
    text-decoration: ;
} */
</style>